package com.tree.rw.demo.service.impl;

import com.tree.rw.demo.annotation.Master;
import com.tree.rw.demo.entity.User;
import com.tree.rw.demo.mapper.UserMapper;
import com.tree.rw.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @ClassName com.tree.rw.demo.service.impl
 * Description: <类功能描述>. <br>
 * <p>
 * <使用说明>
 * </p>
 * @Author tree
 * @Date 2019-06-02 15:37
 * @Version 1.0
 */
@Component
public class UserServiceImpl implements UserService {

    @Autowired
    UserMapper userMapper;


    @Override
    public List<User> getAllUser() {
        return userMapper.getAll();
    }

    @Override
    public User getUserById(int id) {
        return userMapper.getById(id);
    }

    @Override
    public int insert(User user) {
        return userMapper.insert(user);
    }

//    @Master
//    @Override
//    public String getToken(String appId) {
//        //  有些读操作必须读主数据库
//        //  比如，获取微信access_token，因为高峰时期主从同步可能延迟
//        //  这种情况下就必须强制从主数据读
//        return null;
//    }
}
